/**
 * Created by 鹏 on 14-3-11.
 */
var db = require('../common/db');
var enums = require('../common/enum');
var mysql = require('mysql');

exports.signUp = function (newUser, callback) {
    newUser.RegDate = new Date();
    db.execSql("Insert into user Set ?", newUser, function () {
        if (callback != null) {
            callback();
        }
    });
};

exports.verify = function (email, password, callback) {
    db.execSql("select count(*) as c from user where Email = ? and Password = ?", [email, password], function (err, data) {
        if (err) {
            callback(false);
        }
        else {
            callback(data[0].c > 0);
        }
    });
};

exports.getUser = function (email, callback) {
    db.execSql("select * from user where Email =? ", email, function (err, data) {
        if (data.length > 0) {
            callback(data[0]);
        }
        else {
            callback(null);
        }
    });
};